- Notifications
You must be signed in to change notification settings - Fork 1.6k
/
Copy pathsource.cpp
29 lines (21 loc) · 692 Bytes
/
source.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// <Snippet1>
#using <System.dll>
usingnamespaceSystem;
usingnamespaceSystem::Diagnostics;
usingnamespaceSystem::Threading;
intmain()
{
// Create the source, if it does not already exist.
if ( !EventLog::SourceExists( "MySource" ) )
{
EventLog::CreateEventSource( "MySource", "MyNewLog" );
Console::WriteLine( "CreatingEventSource" );
}
// Create an EventLog instance and assign its source.
EventLog^ myLog = gcnew EventLog;
myLog->Source = "MySource";
// Write an informational entry to the event log.
myLog->WriteEntry( "Writing to event log." );
Console::WriteLine( "Message written to event log." );
}
// </Snippet1>